package com.example.viewpagerandlistview.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.viewpagerandlistview.Contents;
import com.example.viewpagerandlistview.R;
import com.example.viewpagerandlistview.adapter.ContentAdapter;

import java.util.ArrayList;
import java.util.List;

public class Fragment1 extends Fragment {

    private View view;
    List<Contents> list;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment1_layout,container,false);
        initData();
        initView();
        initEvent();
        return view;
    }
    private void initView() {
        ListView item = view.findViewById(R.id.lv_item);
        item.setAdapter(new ContentAdapter(getContext(),list));
    }
    private void initData() {
        Contents contents = new Contents("肖慧,","111111111111","binggan");
        Contents contents1 = new Contents("莫水珠,","16673192730","dangao");
        Contents contents2 = new Contents("榕榕,","11111111111111","niunai");
        list = new ArrayList<>();
        list.add(contents);
        list.add(contents1);
        list.add(contents2);
    }
    private void initEvent() {
    }
}
